﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wp.BLL;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SEO();
        }
    }
    void SEO()
    {
        string imageurl = "";       
        string Title = TblOptionManager.CreateInstant().GetOption("SEOTitle");
        string description = TblOptionManager.CreateInstant().GetOption("SEODescription");
        string keywords = TblOptionManager.CreateInstant().GetOption("SEOKeyWord");
        string url = Wp.BLL.TblOptionManager.CreateInstant().GetDomainName() + Request.RawUrl;
        imageurl = UrlBuilder.GetImage("", 100);
        this.Page.Title = Title;
        SetHeaderMetName("description", description);
        SetHeaderMetName("keywords", keywords);

        SetHeaderMetProperty("og:title", Title);
        SetHeaderMetProperty("og:type", "article");
        SetHeaderMetProperty("og:url", url);
        SetHeaderMetProperty("og:image", imageurl);
        SetHeaderMetProperty("og:description", description);
        SetHeaderMetProperty("og:site_name", "Linh Sơn Phật Giáo");
    }
    private void SetHeaderMetName(string Name, string Content)
    {
        HtmlMeta meta = new HtmlMeta();
        meta.Name = Name;
        meta.Content = Content;
        Page.Master.FindControl("head").Controls.AddAt(Page.Master.FindControl("head").Controls.Count - 1, meta);
    }
    private void SetHeaderMetProperty(string Name, string Content)
    {
        HtmlMeta meta = new HtmlMeta();
        meta.Attributes.Add("property", Name);
        meta.Content = Content;
        Page.Master.FindControl("head").Controls.AddAt(Page.Master.FindControl("head").Controls.Count - 1, meta);
    }
}